package ca.seia.comp6521.a1.memory;

import java.io.FileNotFoundException;
import java.util.LinkedList;
import java.util.List;

import org.hamcrest.core.IsEqual;

import ca.seia.comp6521.a1.io.DataFileReader;

public class InputMemoryBuffer extends MemoryBuffer {

	DataFileReader reader; 
	
	public InputMemoryBuffer(String assignedSublistFile, int capacity) throws FileNotFoundException {
		super(assignedSublistFile, capacity);
		this.reader = new DataFileReader(this.assignedSublistFile);
	}
	

	public InputMemoryBuffer(int capacity)
	{
		super(capacity);
	}
	
	public InputMemoryBuffer(int capacity, int id) {
		super(capacity, id);
	}


	public boolean load(){
		
		LinkedList<Integer> integers = new LinkedList<Integer>();
		boolean isEndOfFileReached = this.reader.readNextIntegers(this.capacity, integers);
		this.buffer = integers;
		
		return isEndOfFileReached;
	}
	
	public void setAssignedSublistFile(String assignedSublistFile) throws FileNotFoundException {
		this.buffer.clear();
		this.assignedSublistFile = assignedSublistFile;
		this.reader = new DataFileReader(assignedSublistFile);
	}
	
	
	

}
